"""
relation utilities
"""
import collections
import itertools
import operator
import re

# python 3 notation
map = itertools.imap
zip = itertools.izip

__all__ = ['grep']


def grep(R, regex, flags=0):
    rx = re.compile(regex, flags)
    return R.filter(lambda row:
        rx.search(
            '\0'.join(
                str(x) for x in row
            )
        )
    )



